namespace array_demo.Model.Set
{
    /// <summary>
    /// 无序链表存入set
    /// </summary>
    /// <typeparam name="E"></typeparam>
    public class LinkedSet1<E> : ISet<E>
    {
        private LinkedList1<E> linkedList1;
        public LinkedSet1()
        {
            linkedList1 = new LinkedList1<E>();
        }

        public bool IsEmpty => linkedList1.isEmpty;

        public int Count => linkedList1.count;

        public void Add(E e)
        {
            if (!linkedList1.IsContains(e))
                linkedList1.AddFirst(e);
        }

        public bool Contains(E e)
        {
            return linkedList1.IsContains(e);
        }

        public void Remove(E e)
        {
            linkedList1.Remove(e);
        }
    }
}